<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/10/28
 * Time: 11:44
 */
namespace core\common;

class route{

    private static $c,$a;
    public $r;
    public function __construct()
    {
        if($_SERVER['PATH_INFO']!=""){
            $route=explode('/',$_SERVER['PATH_INFO']);
            $route=array_slice($route,1);
            if(!empty($route[0]) && !empty($route[1])){
                $controller=$route[0];
                $action=$route[1];
            }else{
                $controller='test';
                $action="index";
            }

        }else{
            $controller='test';
            $action="index";
        }
        self::$c=CONTROLLER.$controller;
        self::$a=$action;
        $this->r=new self::$c;
    }

    public  function run(){
        $f=self::$a;
        $this->r->$f();
    }



}